<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:include value="/js/validators/user.jsp"></s:include>
  <div class="f_l margin1" style="width:100%">
    <div style="height:24px;color:red" align="center" id="errorInfo">${failInfo }</div>
    <div style="height:24px;color:red;font-weight:bold" align="left">用户更新</div>
    <s:form id="submitForm" action="user!updateBySelf" method="post" theme="simple">
    <table>
    	<tbody>
    		<tr>
	    		<td><s:text name="姓名"/>：</td>
	    		<td><input maxlength="25" type="text" name="user.userName" value="${user.userName}" /><span></span></td>
	    		<td><s:text name="电子邮箱"/>：</td>
	    		<td><input maxlength="25" type="text" name="user.email"  value="${user.email}" /><span></span></td>
    		</tr>
    		<tr>
    			<td><s:text name="密码"/>：</td>
    			<td><input maxlength="14" type="password" name="user.password" value="${user.password}"></td>
    			<td><s:text name="重复密码"/>：</td>
    			<td><input maxlength="14" type="password" name="user.repassword"  value="${user.password}"></td>
    		</tr>
    		<tr>
    			<td><s:text name="手机"/>：</td>
    			<td><input maxlength="13" type="text" name="user.mobile"  value="${user.mobile}"></td>
    			<td><s:text name="传真"/></td>
    			<td><input maxlength="25" type="text" name="user.fax"  value="${user.fax}"></td>
    		</tr>
    		<tr>
    			<td><s:text name="公司"/>：</td>
    			<td>${user.companyName}</td>
    			<td><s:text name="职位"/>：</td>
    			<td> ${user.positionName}</td>
    		</tr>
    		<tr>
    			<td><s:text name="类型"/>：</td>
    			<td> 
    			  ${user.userTypeName}
    			</td>
    		</tr>
    		<tr>
    			<td colspan="4">
    			     <s:text name="国家"/>：<input maxlength="25" type="text" name="user.country"  value="${user.country}">
           			 <s:text name="省"/>：<input maxlength="25" type="text" name="user.province"  value="${user.province}">
            		 <s:text name="市"/>：<input maxlength="25" type="text" name="user.city"  value="${user.city}">
    			</td>
    		</tr>
    		<tr>
    			<td colspan="4">
    			<s:text name="地址"/>：
    			<input maxlength="50" type="text" name="user.address" style="width: 450px;" value="${user.address}">
    			</td>
    		</tr>
    		<tr>
    			<td align="right" colspan="2">
    				 <input type="submit" value="确认" onclick="return doValidate(event);" />
    			</td>
    			<td align="left" colspan="2">
    				<input type="button" value="取消" onclick="javascript:history.back(-1);"/>
    			</td>
    		</tr>
    	</tbody>
    </table>
        <input type="hidden" id="user.id" name="user.id" value="${user.id}">
        <input type="hidden" id="user.userTypeId" name="user.userTypeId" value="${user.userTypeId}">
        <input type="hidden" id="user.userTypeName" name="user.userTypeName" value="${user.userTypeName}">
        <input type="hidden" id="user.companyName" name="user.companyName" value="${user.companyName}">
        <input type="hidden" id="user.companyId" name="user.companyId" value="${user.companyId}">
        <input type="hidden" id="user.positionId" name="user.positionId" value="${user.positionId}">
        <input type="hidden" id="user.positionName" name="user.positionName" value="${user.positionName}">
    </s:form>
  </div>
  <script type="text/javascript">
	  function getPositions(){
	      var companyId = document.getElementById("user.companyId").value;
	
	      $.ajax({
	    	  type: "POST",
	    	  url: "<s:url action='position!getPositionsByCompanyId' namespace='/position' />",
	    	  data: "companyId=" + companyId,
	    	  complete:function(response){
	          var data = response.responseText;
	    	  if(null != data && "" != data){
			       var positions = data.split(";");
			       var html = "";
			       for(var i = 0; i < positions.length; i++){
			           var p = positions[i].split(",");
			           html += "<option value='" + p[0]+ "'>" + p[1] + "</option>";
			       }
			       $("#positions").html(html);
		        }else{
		           $("#positions").html("<option value=''>无</option>");
		        }
	          }
	      }); 
	  }
  </script>
